#include <bits/stdc++.h>

using namespace std;

const int N = 1e5 + 10;

int a, b , n,ff,tt,FF,TT;
int mp[1005][1005];
int q[1005],Q[1005];
int x[1001][1001],X[1001][1001];
int y[1001][1001],Y[1001][1001];

int main()
{
    cin >> a >> b >> n;
    for(int i = 1; i<= a;i ++)
        for(int j = 1; j<= b; j++)
            cin >> mp[i][j];
    
    for(int i = 1; i<= a;i ++){
        ff = tt = FF = TT = 0;
        for(int j = 1; j<= b; j++){
            while(ff <= tt && j - q[ff] >= n)ff++;
            while(FF <= TT && j - q[FF] >= n)FF++;
            // 进行入队
            while(ff <= tt && mp[i][j] <= mp[i][q[tt]])tt--;

        }
    }
   
   return 0;
}
